function [] = jp2costs(jp2file)
a = readj2k(jp2file);

for i = 1:3
    w = a{1,1}{1,i}.width;
    h = a{1,1}{1,i}.height;
    levels = a{1,1}{1,i}.levels;
    component = a{1,1}{1,i}.data';
    [m, b] = component_cod(component, levels, w, h, i);
    output = get_output_file_name(jp2file)
    count_bits(m, b, i, output);
end;
end

function [str] = get_output_file_name(jp2file)
    f = strrep(jp2file, '\', '_');
    f = strrep(f, '/', '_');
    str = [f(1:length(f) - 4)];
end